tinymce.PluginManager.add('mediaurl', function(editor, url) {
    // Add a button that opens a window
    editor.addButton('mediaurl', {
        text: 'Chèn URL',
        icon: false,
        onclick: function() {
            // Open window
            editor.windowManager.open({
                title: 'Chèn URL',
                body: [
                    {type: 'textbox', name: 'url', label: 'URL'},
					{type: 'textbox', name: 'content', label: 'Nội Dung'}
                ],
                onsubmit: function(e) {
                    // Insert content when the window form is submitted
					if(e.data.url !=''){
						if(e.data.content !=''){
							editor.insertContent('[url='+e.data.url+']' +e.data.content + '[/url]');
						}else{
							editor.insertContent('[url='+e.data.url+']' +e.data.url + '[/url]');
						}
					}
                	
                	
                }
            });
        }
    });

    // Adds a menu item to the tools menu
    editor.addMenuItem('example', {
        text: 'Thêm URL',
        context: 'tools',
        onclick: function() {
            // Open window with a specific url
            editor.windowManager.open({
                title: 'Thêm URL',
                url: 'http://www.tinymce.com',
                width: 800,
                height: 600,
                buttons: [{
                    text: 'Close',
                    onclick: 'close'
                }]
            });
        }
    });
});
